/**
 * @param {string[]} words
 */
export var WordFilter = function (words) {
  this.words = words
}

/**
 * @param {string} pref
 * @param {string} suff
 * @return {number}
 */
WordFilter.prototype.f = function (pref, suff) {
  for (let i = this.words.length - 1; i >= 0; i--) {
    const w = this.words[i]
    console.log(w.slice(0, pref.length), w.slice(-suff.length))
    if (w.slice(0, pref.length) === pref && w.slice(-suff.length) === suff) {
      return i
    }
  }
  return -1
}

/**
 * Your WordFilter object will be instantiated and called as such:
 * var obj = new WordFilter(words)
 * var param_1 = obj.f(pref,suff)
 */
